<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改设备打卡')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-clock-edit" th:object="${cusDeviceClock}">
            <input name="ID" th:field="*{ID}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">设备：</label>
                <div class="col-sm-8">
                    <!-- <input name="deviceId" th:field="*{deviceId}" class="form-control" type="text"> -->
                    <input disabled th:value="*{device_name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">研发项目：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{project_name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">打卡日期：</label>
                <div class="col-sm-8">
                    <input id="clockdatetime" disabled th:value='${cusDeviceClock.clockYear + "-" + cusDeviceClock.clockMonth+ "-" + cusDeviceClock.clockDay}' class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">研发开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDatetime" th:value="${#dates.format(cusDeviceClock.startDatetime, 'yyyy-MM-dd HH:mm')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束研发时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDatetime" th:value="${#dates.format(cusDeviceClock.endDatetime, 'yyyy-MM-dd HH:mm')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">研发操作用户：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{start_user_name}" class="form-control" type="text">
                </div>
            </div>
            <!-- <div class="form-group">    
                <label class="col-sm-3 control-label">结束研发操作人员：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{end_user_name}" class="form-control" type="text">
                </div>
            </div> -->
            <!-- <div class="form-group">    
                <label class="col-sm-3 control-label">打卡年份：</label>
                <div class="col-sm-8">
                    <input name="clockYear" th:field="*{clockYear}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">打卡月份：</label>
                <div class="col-sm-8">
                    <input name="clockMonth" th:field="*{clockMonth}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">打卡日期：</label>
                <div class="col-sm-8">
                    <input name="clockDay" th:field="*{clockDay}" class="form-control" type="text">
                </div>
            </div> -->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/dclock";
        $("#form-clock-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	let ct = $('#clockdatetime').val();
            	
            	let st = $("input[name='startDatetime']").val();
            	if(st.length > 5){ st = st.substring(11)}
            	//$("input[name='startDatetime']").val(ct + " " + st);
            	
            	let et = $("input[name='endDatetime']").val();
            	if(et.length > 5){ et = et.substring(11)}
            	//$("input[name='endDatetime']").val(ct + " " + et);
            	
            	if(st >= et){
            		alert("结束打卡时间必须大于开始打卡时间");
            		return;
            	}
            	
                $.operate.save(prefix + "/edit", $('#form-clock-edit').serialize());
            }
        }

/*         $("input[name='startDatetime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDatetime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        }); */
        
        $("input[name='startDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            startView: 0,
            minView:0,
            maxView:2,
            autoclose: true
        });

        $("input[name='endDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            startView: 0,
            minView:0,
            maxView:2,
            autoclose: true
        });
    </script>
</body>
</html>